class HomeView {
    public show(): void {
        console.log("Displaying Home Page");
    }
}

class StudentView {
    public show(): void {
        console.log("Displaying Student Page");
    }
}

class Dispatcher {
    private studentView: StudentView;
    private homeView: HomeView;
    public constructor() {
        this.studentView = new StudentView();
        this.homeView = new HomeView();
    }
    public dispatch(request: string): void {
        if (request.toUpperCase() === 'STUDENT') {
            this.studentView.show();
        } else {
            this.homeView.show();
        }
    }
}

class FrontController {
    private dispatcher: Dispatcher;
    public constructor() {
        this.dispatcher = new Dispatcher();
    }
    private isAuthenticUser(): boolean {
        console.log('User is authenticated successfully');
        return true;
    }
    private trackRequest(request: string): void {
        console.log(`Page requested: ${request}`);
    }
    public dispatchRequest(request: string): void {
        this.trackRequest(request);
        if (this.isAuthenticUser()) {
            this.dispatcher.dispatch(request);
        }
    }
}

function main() {
    const controller: FrontController = new FrontController();
    controller.dispatchRequest('STUDENT');
    controller.dispatchRequest('HOME');
}

main();
